package pers.wq.model.bean;

import java.util.HashMap;
import java.util.Map;

import pers.wq.BaseController;
import pers.wq.LoginModel;

public class ModelBean {
	private String columns;
	private String title;
	private String table = null;
	private String condition = null;
	private String order = null;
	private String limit = null;
	private static String WQ_ID_TAG = "##WALTY_ID_TAG##";
	private Map<String,String> specialMap;
	private Map<String,String> theadMap;
	
	public String getCondition() {
		return condition;
	}

	public void setCondition(String condition) {
		condition  = condition.replace(WQ_ID_TAG, getNowUserId());
		this.condition = condition;
	}

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}

	public String getLimit() {
		return limit;
	}

	public void setLimit(String limit) {
		this.limit = limit;
	}

	public Map<String,Object> toMap(){
		Map<String,Object> map = new HashMap();
		map.put("title", title);
		map.put("thead", theadMap);
		map.put("special", specialMap);
		return map;
	}
	
	private String getNowUserId(){
		Map<String,Object> map = (Map<String, Object>) BaseController.getSessionLogin();
		return ((LoginModel)map.get("user")).getUsername();
	}
	
	public String getColumns() {
		return columns;
	}
	public void setColumns(String columns) {
		this.columns = columns;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public Map<String, String> getSpecialMap() {
		return specialMap;
	}
	public void setSpecialMap(Map<String, String> specialMap) {
		this.specialMap = specialMap;
	}
	public Map<String, String> getTheadMap() {
		return theadMap;
	}
	public void setTheadMap(Map<String, String> theadMap) {
		this.theadMap = theadMap;
	}

	public String getTable() {
		return table;
	}

	public void setTable(String table) {
		this.table = table;
	}
	
}
